<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>约健</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">

    {include file="public:headfile"}
</head>

<body class="hold-transition sidebar-mini">
<div class="wrapper">

    {include file="public:head"}

    {include file="public:slidemenu"}

    <div class="content-wrapper">

        <section class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1>训练信息管理</h1>
                    </div>
                </div>
            </div>
        </section>



        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-12">
                    <div class="card">
                        <div class="card-header">
                            <h3 class="card-title"><button data-toggle="modal"
                                    data-target="#add">
                                        添加
                                     </button></h3>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body">
                            <table id="example2" class="table table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th>编号</th>
                                    <th>训练名字</th>
                                    <th>训练图片</th>
                                    <th>训练简介</th>
                                    <th>训练等级</th>
                                    <th>训练时间</th>
                                    <th>训练地点</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {volist name="list" id="vo"}   
                                <tr>
                                    <td>{$i}</td>
                                    <td>{$vo.exername}</td>
                                    <td><img src="__STATIC__/img/exerimg/{$vo.exerpic} " style="width: 90px;height:50px"></td>
                                    <td>{$vo.exerintro}</td>
                                    <td><?php 
                                        if($vo['elevel']==0) echo '入门';
                                        if($vo['elevel']==1) echo '菜鸟';
                                        if($vo['elevel']==2) echo '进阶';
                                         ?>
                                    </td>
                                    <td>{$vo.exerstarttime}</td>
                                    <td>{$vo.exeraddress}</td>
                                    <td><button data-toggle="modal"
                                    data-target="#edit" onclick="jsedit({$vo.exerid})">
                                        修改
                                     </button>
                                    <button>
                                        <a style="color: black" href="{:url('SuperAdmin/ExercisesController/delete',['id'=>$vo.exerid])}">
                                        删除
                                        </a>
                                     </button></td>
                                </tr>
                                {/volist}
                                </tbody>
                            </table>
                        </div>
                        <!-- /.card-body -->
                    </div>
                    <!-- /.card -->
                </div>
                <!-- /.col -->
            </div>
            <!-- /.row -->
        </section>
        <!-- /.content -->

    </div>
</div>

<!-- /模态框 -->
 <div class="modal fade" id="add" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
         <h4 class="modal-title" id="myModalLabel">添加训练</h4>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
       
      </div>
      <div class="modal-body">

  <form class="form-horizontal" action="{:url('SuperAdmin/ExercisesController/add')}" method="post" enctype="multipart/form-data">


                    <div class="form-group">
                        <label for="name">训练名称</label>
                        <input type="text" class="form-control" name="name" placeholder="训练名称" id="cname">
                    </div>
                    <div class="form-group">
                        <label for="name">图片</label>
                        <input type="file" class="form-control" name="pic" placeholder="图片" id="pic">
                    </div>
                    <div class="form-group">
                        <label for="name">训练简介</label>
                        <input type="text" class="form-control" name="intro" placeholder="训练简介" id="cintro">
                    </div>                    
                       <div class="form-group">
                        <label for="name">训练时间</label>
                        <input type="text" class="form-control" name="opentime" placeholder="训练时间" id="copentime">
                    </div>
                        <div class="form-group">
                        <label for="name">训练地点</label>
                        <input type="text" class="form-control" name="address" placeholder="训练地点" id="caddress">
                    </div>
                    <div class="form-group">
                        <label for="name">培训等级</label>
                    <select name="level" class="form-control">
                        <option value="0">入门</option>
                        <option value="1">菜鸟</option>
                        <option value="2">进阶</option>
                    </select>
                    </div>
                  
  <div class="form-group">
    <div class="col-md-offset-2 col-md-10">
      
    

  </div>
</div>

    </div>
      <div class="modal-footer">
<input type="submit" name="" value="提交" class="btn btn-default">
      </form>
              <button type="button" class="btn btn-default" onclick="location.replace('index.html')" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>  
<!-- /模态框结束 -->

<!-- /模态框 -->
 <div class="modal fade" id="edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
         <h4 class="modal-title" id="myModalLabel">修改训练信息</h4>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
       
      </div>
      <div class="modal-body">

  <form class="form-horizontal" action="{:url('SuperAdmin/ExercisesController/edit')}" method="post" enctype="multipart/form-data">


                    <div class="form-group">
                        <label for="name">训练名称</label>
                        <input type="text" class="form-control" name="name" placeholder="训练名称" id="name">
                    </div>
                    <div class="form-group">
                        <label for="name">图片</label>
                        <input type="file" class="form-control" name="pic" placeholder="图片" id="pic">
                    </div>
                    <div class="form-group">
                        <label for="name">训练简介</label>
                        <input type="text" class="form-control" name="intro" placeholder="训练简介" id="intro">
                    </div>                    
                       <div class="form-group">
                        <label for="name">训练时间</label>
                        <input type="text" class="form-control" name="opentime" placeholder="训练时间" id="opentime">
                    </div>
                        <div class="form-group">
                        <label for="name">训练地点</label>
                        <input type="text" class="form-control" name="address" placeholder="训练地点" id="address">
                    </div>
                    <input type="hidden" name="exerid" value="" id="hidden" >
                    <div class="form-group">
                        <label for="name">培训等级</label>
                    <select name="level" class="form-control" id="level">
                        <option value="0">入门</option>
                        <option value="1">菜鸟</option>
                        <option value="2">进阶</option>
                    </select>
                    </div>
                  
  <div class="form-group">
    <div class="col-md-offset-2 col-md-10">
      
    

  </div>
</div>

    </div>
      <div class="modal-footer">
<input type="submit" name="" value="提交" class="btn btn-default">
      </form>
              <button type="button" class="btn btn-default" onclick="location.replace('index.html')" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>  
<!-- /模态框结束 -->

<script type="text/javascript">
        function jsedit(exerid)
        {
            //console.log(aid);
           $.ajax({
            url:"{:url('ExercisesController/show')}",
            data:{
                "exerid":exerid
            },
            dataType:'json',
            success(data){
               console.log(data);
          $("#name").val(data.exername);

          $("#intro").val(data.exerintro);

          $("#opentime").val(data.exerstarttime);

           $("#address").val(data.exeraddress);

           $("#level").val(data.elevel);

           $("#hidden").val(data.exerid);

          $("#edit").modal.show;

            }
        }); 
        }

    </script>

{include file="public:footfile"}

</body>

</html>